home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Best way to insert in file
- Date: 28 Feb 1996 08:09:04 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h1un0INNl97@anvil.ugrad.cs.ubc.ca>
- References: <13c_9602272020@amphigory.com>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <13c_9602272020@amphigory.com>, Pazuzu <Pazuzu@amphigory.com> wrote:
- >>From: Bryan Liles
- >>To: All
- >>Subject: Best way to insert in file
- >>Date: 23 Feb 96 17:03:33
- >
- >>Subject: Best way to insert in file
- >>From: stork@serv2.fwi.com (Bryan Liles)
- >>Organization: Fort Wayne Internet
- >
- >>What would be the best way to insert data in to the middle of a text file?
- >>I have a program that is supposed to automatically fill out an application.
- >>(its a an internic domain app)
- >
- >
- >In DOS? It's impossible. You'd have to read up to the insertion point into a
- >temp file, put the inserted text at the end of the temp file, then plop in the
- >rest of the original file. It's a pain in the ass.
-
- Not really. It's called ``filtering''. Inserting into a file is too
- inefficient. Some filesystems have the feature.
-
- A program to fill applications should probably be done in perl, or even the
- bourne shell. In these languages it is easy to output multi-line text
- intermixed with variables. You can just paste the text of the application into
- the program, and put variables in the right places. For example:
-
- #!/bin/sh
-
- echo "Enter your name"
- read NAME
- echo "Enter your address"
- read ADDR
-
- cat > application <<END
- $NAME needs to get a life.
- Please send one to:
- $ADDR
- END
-
- Really, while the general problem of inserting lines into text files in C is
- legitimate for comp.lang.c, C is not necessarily the best tool for this
- particular application.
- --
-
-